const HtmlWebpackPlugin = require('html-webpack-plugin')

const { resolve } = require('path')
const htmlPublicPath = resolve(__dirname, 'build')

module.exports = {
  entry: './src/js/index.js',
  output: {
    filename: 'js/built.js',
    path: htmlPublicPath,
    publicPath: './',
  },
  module: {
    rules: [
      {
        /**
         * 语法检查: eslint-loader (依赖库 eslint)
         *  注意：只检查自己写的代码，第三方的库不用检查  exclude - node_modules
         *  设置检查规则：`airbnb`  看 `.eslintrc.js`
         */
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          // 自动修改 错误
          fix: true,
        }
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './src/index.html'
    })
  ]
}